package com.xuecheng.order.controller;

import com.xuecheng.commons.model.vo.OrdersVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import org.springframework.web.bind.annotation.*;
import com.xuecheng.order.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;

/**
 * <p>
 * 订单前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
public class OrdersController {

    @Autowired
    private OrdersService  ordersService;

    //用户下单
    @PostMapping("/orders/create/{coursePubId}")
    public ResponseResult<String> createOrder(@PathVariable("coursePubId")Long coursePubId) throws IOException {
        return ordersService.createOrder(coursePubId);
    }

    //根据订单编号查询支付是否成功
    @GetMapping("/orders/{orderNo}")
    public ResponseResult<OrdersVo> isPay(@PathVariable("orderNo")String orderNo) throws IOException {
        return ordersService.isPay(orderNo);
    }
}
